package com.itheima.dao.store;

import com.itheima.domain.store.Question;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface QuestionMapper {
    @Insert("insert into st_question (id,catalog_id,catalog_name,company_id,company_name,remark,subject,analysis,type,difficulty,is_classic,state,picture,create_time,update_time) " +
            "values (#{id},#{catalogId},#{catalogName},#{companyId},#{companyName},#{remark},#{subject},#{analysis},#{type},#{difficulty},#{isClassic},#{state},#{picture},now(),now())")
    void addQuestion(Question question);

    //根据id删除此数据
    @Delete("delete from st_question where id=#{id}")
    void deleteQuestion(@Param("id") String id);

    /**
     * 修改问题
     * 2021/10/18 14:51
     * created by yangyawen
     * @param question
     */
    @Update("update st_question set picture=#{picture},catalog_id=#{catalogId},catalog_name=#{catalogName}," +
            "subject=#{subject},type=#{type},difficulty=#{difficulty},analysis=#{analysis}," +
            "remark=#{remark},is_classic=#{isClassic},state=#{state},review_status=#{reviewStatus}," +
            "company_name=#{companyName},company_id=#{companyId},update_time=now() where id=#{id}")
    void updateQuestion(Question question);

    //查询所有
//    @Select("select * from st_question order by update_time desc")
    List<Question> findAll();

    // 通过id查询此数据
    @Select("select * from st_question where id=#{id}")
    Question findQuestionById(@Param("id") String id);

    /**
     * 审核
     * @param id
     */
    @Update("update st_question set review_status='1' where id=#{id}")
    void toExamine(@Param("id") String id);
}
